package com.sun;

import java.util.regex.Matcher;

public class ReplaceTest {
    public static void main(String[] args) {
        String str = "测试数据？";
        String replacement = "test$";
        /*System.out.println("replace:"+str.replace("\\？",replacement));
        System.out.println("replaceAll:"+str.replaceAll("\\？",replacement));
        System.out.println("replaceFirst:"+str.replaceFirst("\\？",replacement));*/
        System.out.println("replace:"+str.replace("？",replacement));
        System.out.println("replaceAll:"+str.replaceAll("\\？", Matcher.quoteReplacement(replacement)));
        System.out.println("replaceFirst:"+str.replaceFirst("\\？",Matcher.quoteReplacement(replacement)));
    }
}
